package com.sky.mapper;


import com.sky.entity.Dish;
import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {


    //@Select("select setmea_id from setmeal_dish where dish_id in dishId")
    List<Long> getSetmealIdsDishIds(List<Long> dishId);

    void insertBatch(List<SetmealDish> setmealDishes);


    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBatch(Long setmealId);

    @Select("select * from setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getBySetmealId(Long setmealId);


    @Delete("delete from setmeal_dish where setmeal_id = #{setmealId}")
    void deleteBySetmealId(Long setmealId);


    //@Select("select dish.* from dish left join setmeal_dish  on dish.id == setmeal_dish.dish_id where setmeal_dish.setmeal_id == #{id} ")
    @Select("select a.* from dish a left join setmeal_dish b on a.id = b.dish_id where b.setmeal_id = #{setmealId}")
    List<Dish> getDishesBySetmealId(Long id);
}
